<!DOCTYPE html>
<html>
<head>
	<title></title>
	<style>
		#div1 {
			width:100px;
			height: 100px;
			background: red;
			position: absolute;
			right: 0;

		}	
	</style>
</head>
<body style="height:2000px;">
<div id="div1">
		
</div>
<script type="text/javascript">
	window.onresize=window.onload=window.onscroll=function(){
		var oDiv=document.getElementById('div1')
		var scrollTop=document.documentElement.scrollTop || document.body.scrollTop;
		var t=(document.documentElement.clientHeight-oDiv.offsetHeight)/2

		oDiv.style.top=scrollTop+t+'px';
	}
</script>
</body>
</html>